home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- global string $ListPaintableItem[];
- global int $ListPaintableRegistInit;
-
- global proc selectPaintableItem(
- string $obj,
- string $node,
- string $attr
- )
- {
- // get the surface list
- string $surfaceList[], $cmd;
- $cmd = "listPaintable -getsurface \"" + $node + "\"";
- $surfaceList = `eval $cmd`;
-
- // select the surface
- select -cl;
- $cmd = "select -r ";
- for( $s in $surfaceList ) {
- // Avoid selecting intermediate objects
- //
- int $io = `getAttr ($s+".io")`;
- if ($io == 0) {
- $cmd += $s + " ";
- }
- }
- eval $cmd;
-
- // set the current Tool
- $cmd = "listPaintable -getcontext \"" + $node + "\"";
- string $context = `eval $cmd`;
-
- if( "skinPaintContext" == $context ) {
- skinPaintToolScript( 4 );
- }
- else if( "polyClrVertPaintContext" == $context ) {
- polyClrVertPaintToolScript( 4 );
- }
- else {
- attrPaintToolScript( 4 );
- }
-
- // Now, `currentCtx` and $context are the same...
-
- // set the selection node and attr
- $s = $obj + "." + $attr;
- attrPaintCtx -e -oth $obj $context;
- attrPaintCtx -e -ath $s $context;
- attrPaintCtx -e -sdn $node $context;
- }
-
-
- global proc createPaintingAttrItems(
- string $parent,
- int $index,
- string $obj
- )
- //
- // Description:
- // Creates a menu that shows all the paintable attributes
- //
- {
- global string $ListPaintableItem[];
-
- popupMenu -e -dai $parent;
- setParent -menu $parent;
-
- string $menu, $buffer[];
- int $size = size($ListPaintableItem);
- int $i;
- for( $i = $index; $i < $size; $i++ ) {
- tokenize( $ListPaintableItem[$i], ".", $buffer );
- if( $obj != $buffer[1] ) {
- break;
- }
- else {
- $menu = `menuItem -l $buffer[2]`;
- menuItem -e -c ( "selectPaintableItem " + $buffer[0] + " " + $obj + " " + $buffer[2] ) $menu;
- setParent -m $parent;
- }
- }
- }
-
-
- global proc createPaintingMenuItems(
- string $parent,
- string $item
- )
- //
- // Description:
- // Creates a menu that shows all the paintable objects and
- // their attributes in the currenct selection
- //
- {
- string $shape = "";
-
- // Look at the shape child of this object
- //
- string $object[] = `listRelatives -path -s $item`;
-
- int $i;
- for ($i = 0; $i < size($object); ++$i) {
- if ( (`nodeType $object[$i]` == "nurbsSurface") ||
- (`nodeType $object[$i]` == "mesh") ) {
- if (getAttr($object[$i] + ".io") == 0) {
- $shape = $object[$i];
- break;
- }
- }
- }
-
-
- //==================================================================
- // If the $shape is a cloth mesh, set up cloth property paint tool
- // differently and return from here. We check if mayaCloth is
- // licensed by checking pluginInfo. Actually, if without mayaCloth
- // plugin loaded, we can not paint on the cloth mesh.
- //
- if( `pluginInfo -q -l "CpClothPlugin"` )
- {
- // isClothMesh is a script defined in clothPaintCallback.
- //
- string $srcString = "source clothPaintCallback";
- eval $srcString;
-
- if( isClothMesh($shape) )
- {
- createClothPaintMenuItems( $parent, $shape );
- return;
- }
- }
- //==================================================================
-
- // if there is no shape, then just return
- //
- if( $shape == "" ) {
- menuItem -l "(empty)" -en false;
- return;
- }
-
- global int $ListPaintableRegistInit;
- global string $ListPaintableItem[];
-
- // initialize the regist list if necessary
- //
- if( !$ListPaintableRegistInit ) {
- ListPaintableRegist();
- $ListPaintableRegistInit = true;
- }
-
- clear $ListPaintableItem;
-
- popupMenu -e -dai $parent;
- setParent -menu $parent;
-
- string $cmd;
- if( $shape == $item ) {
- $cmd = "listPaintable -re1 " + $shape;
- }
- else {
- $cmd = "listPaintable -re2 " + $item + " " + $shape;
- }
- $ListPaintableItem = `eval $cmd`;
-
-
- string $obj, $buffer[];
- int $i;
- int $size = size( $ListPaintableItem );
-
- if( $size == 0 ) {
- menuItem -l "(empty)" -en false;
- }
- else {
- string $menu;
-
- for( $i = 0, $obj = ""; $i < $size; $i++ ) {
- tokenize( $ListPaintableItem[$i], ".", $buffer );
- if( $obj != $buffer[1] ) {
- $obj = $buffer[1];
- // new paintable obj
- $menu = `menuItem -subMenu true -l $obj`;
- menu -e -pmc ( "createPaintingAttrItems \""+$menu+"\" " + $i + " " + $obj ) $menu;
- setParent -m $parent;
- }
- }
- }
- }
-